{% set pypi_name = 'oslo.config' %}
{% set upstream_version = upstream_version('8.3.3') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch('oslo.config') }}
Summary:        OpenStack common configuration library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PyYAML') }}
BuildRequires:  {{ py3('debtcollector') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('importlib-metadata') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('netaddr') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('requests') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('rfc3986') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
The Oslo project intends to produce a python library containing
infrastructure code shared by OpenStack projects. The APIs provided
by the project should be high quality, stable, consistent and generally
useful.

The oslo-config library is a command line and configuration file
parsing library from the Oslo project.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack common configuration library
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('importlib-metadata') }}
Requires:       {{ py3('netaddr') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('rfc3986') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 8.0.1
%endif

%description -n {{ py2name(py_versions='py3') }}
The Oslo project intends to produce a python library containing
infrastructure code shared by OpenStack projects. The APIs provided
by the project should be high quality, stable, consistent and generally
useful.

The oslo-config library is a command line and configuration file
parsing library from the Oslo project.

This package contains the Python 3.x module.

%package -n python-oslo.config-doc
Summary:       Documentation for OpenStack common configuration library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-apidoc') }}

%description -n python-oslo.config-doc
Documentation for the oslo-config library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

PBR_VERSION={{ upstream_version }} PYTHONPATH=. \
    %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
# Requires oslo.log which we can't depend on for build cycle reasons
rm -v oslo_config/tests/test_cfg.py
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%{_bindir}/oslo-config-generator
%{_bindir}/oslo-config-validator
%{python3_sitelib}/oslo_config
%{python3_sitelib}/*.egg-info

%files -n python-oslo.config-doc
%doc doc/build/html README.rst
%license LICENSE

%changelog
